package st.business.tepth.business.user.busnumber.workholder.maintain;

import st.business.tepth.base.OnDataConvertListener;
import st.business.tepth.business.bean.BusInfoWrapperBean;

/**
 * @author zhangyu
 * @date 2019/4/11
 */
public class MaintainWorkHolderPresenter extends MaintainWorkHolderContract.Presenter {
    private final MaintainWorkHolderContract.View mView;
    private final MaintainWorkHolderContract.Model mModel;

    public MaintainWorkHolderPresenter(MaintainWorkHolderContract.View view) {
        mView = view;
        mModel = new MaintainWorkHolderModel();
    }

    @Override
    void getWorkInfo(String token, int repairId) {
        addDisposable(mModel.getWorkInfo(token, repairId,
                new OnDataConvertListener<BusInfoWrapperBean>() {
                    @Override
                    public void convert(BusInfoWrapperBean workInfoBean) {
                        if (mView != null) {
                            mView.showWorkInfo(workInfoBean);
                        }
                    }

                    @Override
                    public void error(int code, String msg) {
                        if (mView != null) {
                            mView.showWorkInfo(null);
                        }
                    }
                }));
    }
}
